From: Roger Pau Monné Date: Wed, 26 Oct 2022 12:56:58 +0000 (+0200) Subject: vpci/msix: remove from table list on detach X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~99 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=c14aea137eab29eb9c30bfad745a00c65ad21066;p=xen.git vpci/msix: remove from table list on detach Teardown of MSIX vPCI related data doesn't currently remove the MSIX device data from the list of MSIX tables handled by the domain, leading to a use-after-free of the data in the msix structure. Remove the structure from the list before freeing in order to solve it. Reported-by: Jan Beulich Fixes: d6281be9d0 ('vpci/msix: add MSI-X handlers') Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich Release-acked-by: Henry Wang --- diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 647f7af679..98198dc2c9 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -51,8 +51,12 @@ void vpci_remove_device(struct pci_dev *pdev) xfree(r); } spin_unlock(&pdev->vpci->lock); - if ( pdev->vpci->msix && pdev->vpci->msix->pba ) - iounmap(pdev->vpci->msix->pba); + if ( pdev->vpci->msix ) + { + list_del(&pdev->vpci->msix->next); + if ( pdev->vpci->msix->pba ) + iounmap(pdev->vpci->msix->pba); + } xfree(pdev->vpci->msix); xfree(pdev->vpci->msi); xfree(pdev->vpci);